home *** CD-ROM | disk | FTP | other *** search
- In article <2ou52f$636@caladan.restena.lu> Kries Roger <kries@crpht.lu> writes:
- |I'm having some problems writing Berkley Sockets API compatible code to
- |connect to a machine with a timeout value. That's to say, I want to
- |connect to a machine, but if I cannot connect until the timeout is
- |elapsed I give up.
- |
- |My solution was to call connect() on a non-blocking socket and then to
- |call select() with the timeout value and to check if the socket is
- |writeable.
- [...]
- |All this seems to be very fine, but after testing the method on
- |a PC with Trumpet Winsock.dll, on a macintosh with a special socket
- |library (GUSI) and on a HP-UX machine, the following problem arises:
- |
- | If at the moment of the connect call, the remote machine has no socket
- | created that listens to the specified port, the following select() call
- | will always timeout, even if during the timeout interval a program is
- | started that listens to the port. That means that in the case where a
- | blocking connect call would return ECONNREFUSED, a non-blocking returns
- | WSAWOULDBLOCK, but the select call always timeouts.
-
- Which fd_set are you putting the sock into for the select call?
- To detect a successful connect(), you need the sock in 'writefds',
- and to check an unsuccessful connect() you need the socket in 'exceptfds'.
-
- Assuming you are doing both of these,
- This is broken behaviour - do all the platforms you have tested with
- act this way?
-
- If there is no listener on the remote machine, the non-blocking connect()
- can't tell, so returning error WSAEWOULDBLOCK is correct.
- You then call select(), with the socket of interest in both 'writefds' and
- 'exceptfds',and as soon as the RST arrives back, your select should
- return with the socket in exceptfds marked.
-
- On another note, I have seen recommended in a few places that connect()
- should NOT return immediately it gets back a RST, with WSAECONNREFUSED -
- it should keep trying, just as it would if there was no response at all,
- and return WSAECONNREFUSED after the normal timeout time. This
- guards against connections failing purely because of a loss of
- synchronisation, where the server was just a little too slow to
- get the socket listening before the client tries to connect. The
- first SYN may cause a RST to come back, but the next attempt
- should catch the listener finally up and running.
-
- --
- Paul Brooks |paul@abccomp.oz.au |Emerging Standard:
- TurboSoft Pty Ltd |pwb@newt.phys.unsw.edu.au| one that has not yet
- 579 Harris St., Ultimo | | been superseded.
- Sydney Australia 2007 |ph: +61 2 281 3155 |
- From news@bigblue.oit.unc.edu Tue Apr 22 12:17:01 1994
- Received: from bigblue.oit.unc.edu by SunSITE.Unc.EDU (5.65c+IDA/FvK-1.07) with SMTP
- id AA01788; Sun, 24 Apr 1994 12:44:32 -0400
- Received: by bigblue.oit.unc.edu (AIX 3.2/UCB 5.64/4.03)
- id AA32224; Sun, 24 Apr 1994 11:12:19 -0500
- Received: from GATEWAY by bigblue with netnews
- for winsock@sunsite.unc.edu (winsock@sunsite.unc.edu)
- To: winsock@sunsite.unc.edu
- Date: 22 Apr 1994 12:17:01 GMT
- From: frank@e-technik.tu-ilmenau.de (Frank Becker)
- Message-Id: <2p8f7t$4a@prakinf2.PrakInf.TU-Ilmenau.DE>
- Organization: Resumix, Inc., Santa Clara, CA
- Sender: ses
- Reply-To: frank@e-technik.tu-ilmenau.de
- Subject: PCNFS 4.0 and winsock.dll ??
-
- I've installed Sun-PC-NFS 4.0 and Windows 3.1. Then I wanted to use NCSA Mosaic 2.0a4.
- Therefore I needed winsock.dll. I tried different versions of winsock.dll, but if I start Mosaic a message appear "failed initialize winsock.dll".
- I know a configuration with PC-NFS 5.0 and WfW 3.11 works very fine.
- Who knows about the problem of interworking between PC-NFS 4.0 and winsock.dll??
- Do I have to setup my winsock.dll (I copied the file in my NFS-directory)??
- What is wrong??
-
- Thank you Frank
-
-
-
-